package com.example.test11_1;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        EditText numberTV = (EditText) findViewById(R.id.editText);
        Button dial = (Button) findViewById(R.id.button);
        dial.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                final String number = numberTV.getText().toString();//获取输入的电话号码
                Intent intent = new Intent();
                intent.setAction(Intent.ACTION_CALL);//为intent设置动作
                intent.setData(Uri.parse("tel:"+number));//为intent设置数据
                startActivity(intent);//将intent传递给Activity
            }
        });
    }
}